<template>
  <div class="exhibits-content" :style="{ width: props.info.width + 0.9 + 'rem', height: props.info.height + 'rem' }">
    <div class="content-box" v-for="(item, index) in props.info.showpieceList" :key="index">
      <div class="item-parent" @contextmenu.stop="emit('onContextMenuChild', $event, index)">
        <div class="cover" @click="viewImg(item.moduleId, item.id)">
          <img class="cover-img" :src="getLinkUrl(item.coverUrl,'?imageView2/3/w/600/format/webp')" alt="" />
          <!-- <img v-if="route.meta.loopType" class="flower-btn" :src="publicUrls + 'free/style4/flower.webp'" /> -->
        </div>
      </div>
      <div class="exhibits-name">
        <div class="name-text">
          {{ item.name }}
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts">
export default defineComponent({
  name: 'free4Style6',
});
</script>
<script lang="ts" setup>
import { urls, getLinkUrl } from '@/utils/request/upload';
import { publicUrls } from '@/utils/minxin';
import { DraggableContainer } from 'vue3-draggable-resizable';
// import FlotMenu from '@/components/flotMenu/OutlineMenu.vue';
import ContextMenu from '@imengyu/vue3-context-menu';
import { getDraggableNumber, getExhibitsHeightRest, getdisabledY } from '@/utils/getRemComputed';
import { ref, reactive, watch, nextTick, defineComponent } from 'vue';
import { exbitMenuShow, exbitListMenuShow } from '@/hooks/menuHooks';
import { useProjectStore } from '@/store';
import { useRoute } from 'vue-router';

const emit = defineEmits([
  'emitChildItemDraggable',
  'emitChildItemDraggableStyle',
  'emitShowcaseDraggable',
  'emitShowcaseDraggableStyle',
  'onContextMenuChild',
]);
const store = useProjectStore();
const contextMenuTrigger = ref(); //列表盒子dom
const parentLock = ref(true);
const childShow = ref(true);
const draggableResizable = ref(); //父级拖拽盒子ref
const timer = ref();
const route = useRoute();
const ImgVisible = ref(false);
const ImgUrl = ref('');

const props = defineProps({
  width: {
    type: Number || String,
  },
  height: {
    type: Number || String,
  },
  indexs: {
    type: Number,
  },
  info: {
    type: Object,
  },
  childId: {
    type: Number,
  },
  AuxiliaryId: {
    type: Number,
  },
});
const emitChildItemDraggable = (draggingInfo: any, childIndex: number) => {
  emit('emitChildItemDraggable', draggingInfo, childIndex); //分组传递当前展品图距离相对父元素的xy偏移量变化
};
const emitChildItemDraggableStyle = (draggingInfo: any, childIndex: number) => {
  emit('emitChildItemDraggableStyle', draggingInfo, childIndex); //分组设置当前展品图距离相对父元素的宽高变化
};
const emitShowcaseDraggable = (draggingInfo: any) => {
  emit('emitShowcaseDraggable', draggingInfo); //传递当前展柜图距离相对父元素的xy偏移量变化
};
const emitShowcaseDraggableStyle = (draggingInfo: any) => {
  emit('emitShowcaseDraggableStyle', draggingInfo); //传递当前展柜距离相对父元素的宽高变化
};

const handleMouseDown = (event) => {
  event.stopPropagation();
};
const preventDefaultDrag = (event) => {
  event.stopPropagation();
};

const viewImg = (moduleId: number, e?: number) => {
  store.exhibitsModuleId = moduleId;
  store.exhibitsShowpieceid = e;
  store.exhibitsInfoShow = true;
};

// watch(
//   () => props.info.width,
//   () => {
//     childShow.value = false;
//     nextTick(() => {
//       childShow.value = true;
//     });
//   },
//   { deep: true },
// );
// watch(
//   () => props.info.height,
//   () => {
//     childShow.value = false;
//     nextTick(() => {
//       childShow.value = true;
//     });
//   },
//   { deep: true },
// );

//
</script>

<style lang="less" scoped>
.exhibits-content {
  position: relative;
  display: flex;
  justify-content: center;
  z-index: 999;
  padding-top: 4px !important;
  -webkit-box-reflect: below 40% linear-gradient(transparent, rgba(0, 0, 0, 0.5));
  margin-top: 3px;
  margin: 0 20px;
}
.content-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-right: 76px;
}
.content-box:last-child {
  margin: 0;
}
.content-box:nth-child(2n) {
  margin-top: 60px;
}
.item-parent {
  position: relative;
  flex-shrink: 0;
  width: 557px;
  height: 342px;
  background: url('https://static.jiyi.show/free/style4/displayBoardStyle6Bg.webp') no-repeat center/100% 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}
.cover {
  width: 257px;
  height: 257px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  border-radius: 999px;
  transform: translateY(3px);
  .cover-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: all 0.5s;
  }
  &:hover {
    .cover-img {
      transform: scale(1.2);
    }
  }
}
.exhibits-name {
  flex-shrink: 0;
  width: 358px;
  height: 48px;
  margin-top: 20px;
  background: url('https://static.jiyi.show/free/style4/exhibitsNameBg.png') no-repeat center/100% 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  .name-text {
    width: 308px;
    color: #fcffff;
    text-align: center;
    font-family: 'PingFang SC';
    font-size: 16px;
    font-style: normal;
    font-weight: 500;
    line-height: 32px; /* 200% */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
.flower-btn {
  width: 40px;
  height: 40px;
  object-fit: cover;
  position: absolute;
  top: 50%;
  left: 56%;
  transform: translate(-56%, -50%);
  animation: flower 2s linear infinite;
  @keyframes flower {
    0% {
      opacity: 0;
    }
    40% {
      opacity: 100%;
    }
    60% {
      opacity: 100%;
    }
    100% {
      opacity: 0;
    }
  }
}
</style>
